package com.mapfinal.server.layer;

import com.mapfinal.server.layer.model.MfLayer;
import com.mapfinal.server.layer.model.MfStyle;

public abstract class AbstractServerLayer implements ServerLayer {

	private MfLayer mfLayer;
	private MfStyle mfStyle;
	
	public AbstractServerLayer(MfLayer mfLayer) {
		this.setMfLayer(mfLayer);
		if(mfLayer!=null) {
			String style = mfLayer.getStyle();
			if(style!=null) {
				mfStyle = MfStyle.service().getStyle(style);
			} else {
				mfStyle = MfStyle.service().getDefault(mfLayer.getGeotype());
			}
		}
	}
	
	@Override
	public String getType() {
		// TODO Auto-generated method stub
		int type = mfLayer.getLayertype();
		switch (type) {
		case 0:
			return ServerLayerType.vector.name();
		case 1:
			return ServerLayerType.raster.name();
		case 2:
			return ServerLayerType.online_tile.name();
		case 3:
			return ServerLayerType.offline_tile.name();
		}
		return null;
	}

	@Override
	public MfLayer getMfLayer() {
		// TODO Auto-generated method stub
		return mfLayer;
	}

	public void setMfLayer(MfLayer mfLayer) {
		this.mfLayer = mfLayer;
	}

	public MfStyle getMfStyle() {
		return mfStyle;
	}

	public void setMfStyle(MfStyle mfStyle) {
		this.mfStyle = mfStyle;
	}

}
